<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title>评论列表</title>
		<link rel="stylesheet" href="/dvmini/res/plugins/layui/css/layui.css">
		<link rel="stylesheet" href="/dvmini/res/css/basic.css">
	</head>
	<style>
	.Detailbtn .layui-form-label{
		width:90px;	
	}
	.Detailbtn .layui-input-inline{
		width:380px !important;
	}
	</style>
	<body class="wrap">
		<form class="layui-form">
			<div class="layui-form-item searchbox" style="margin-bottom: 0px;">
				<div class="layui-input-inline" style="width: 150px;">
					<select name="estateid">
						<option value="">楼盘名称</option>
						<option value="1">万科·皇马郦宫</option>
						<option value="2">万科·四季松湖</option>
						<option value="3">南部湾万科城</option>
						<option value="4">万科·翡丽山</option>
						<option value="5">万科·东江之星</option>
						<option value="6">万科·幸福城</option>
						<option value="7">万科·云城</option>
						<option value="8">万科·城市花园</option>
						<option value="9">万科·中央公园</option>
						<option value="10">万科·珠江东岸</option>
					</select>
				</div>
				<button class="layui-btn" lay-submit lay-filter="querybtn">查询</button>
				<button class="layui-btn layui-btn-primary" lay-submit lay-filter="resetbtn" type="reset">重置</button>
			</div>
		</form>
		<table class="layui-table">
			<thead>
				<tr>
					<th style="width:30px;">No</th>
					<th style="min-width: 60px;">粉丝</th>
					<th style="min-width: 120px;">评论内容</th>
					<th style="min-width: 70px;">楼盘名称</th>
					<th style="min-width: 56px;">评论时间</th>
					
				</tr>
			</thead>
				
			<tbody id="remarklist">
			
			</tbody>
		</table>
		<div class="nulldata">暂无数据</div>
		<div id="page"></div>
		
	</body>
	<script src='/dvmini/res/js/jquery.min.js'></script>
	<script src="/dvmini/res/plugins/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript" src="/dvmini/res/js/me.js"></script>
	<script>
		layui.use(['form', 'element', 'laydate', 'layer', 'laypage'], function() {
			var form = layui.form(),
				element = layui.element(),
				laydate = layui.laydate,
				layer = layui.layer,
				laypage = layui.laypage;
			
			var queryObj={
				page : 1,
				pagesize:10,
				estateid:''
			};
			
			initData(queryObj);

			function initData(queryObj){
				$.post("/dvmini/report/getRemarksList",queryObj,function(data){
					console.log(data)
					data=data.data;
					
					laypage({
						cont: 'page',
						pages: data.totalPages, 
						curr: queryObj.page,
						skip: true,
						jump: function(obj, first) {
							if(!first) {
								queryObj.page = obj.curr
								initData(queryObj)
							}
						}
					});
					
					$("#remarklist").html("")
					
					if(data.rows.length>0){
						$(".nulldata").hide()
						var str="";
						for(var i=0;i<data.rows.length;i++){
							var nick="";
							if((data.rows[i].nickname==null||data.rows[i].nickname=="")&&(data.rows[i].logo==null||data.rows[i].logo=="")){
								nick='<div style="text-align:left;">未授权（id：'+ data.rows[i].id +'）</div>';
							}else{
								if(data.rows[i].logo==null||data.rows[i].logo==""){
									nick='<div class="nickbox"><div id="wlogo" style="background:url(/dvmini/res/images/default_user.png) no-repeat center;-webkit-background-size:contain;background-size:contain;"></div><span class="nick"> '+ data.rows[i].nickname +'</span></div>';
								}else{
									nick='<div class="nickbox"><div id="wlogo" style="background:url('+data.rows[i].logo+') no-repeat center;-webkit-background-size:contain;background-size:contain;"></div><span class="nick"> '+ data.rows[i].nickname +'</span></div>';
								}
							}
							str+='<tr data-id='+ data.rows[i].id +'>'
								+'<td>'+ ((data.page - 1) * data.pageSize + i + 1) +'</td>'
								+'<td style="text-align:left;">'+ nick +'</td>'
								+'<td style="text-align:left;">'+ data.rows[i].content+'</td>'
								+'<td>'+ estateName(data.rows[i].estateid) +'</td>'
								+'<td>'+ toTime_G(data.rows[i].createdtime) +'</td>'
								+'</tr>'
						}
						$("#remarklist").html(str)
						toNull_G();
					}else{
						$(".nulldata").show()
						return false;
					}
				})
			}
			
			//查询
			form.on("submit(querybtn)", function(e){
				queryObj.estateid=e.field.estateid;
				queryObj.page=1;
				initData(queryObj)
				return false
			})
			
			//重置
			form.on("submit(resetbtn)", function(e){
				$("[name=estateid]").val("")
				queryObj={
						page : 1,
						pagesize:10,
						estateid : ""
				};
				form.render();
				initData(queryObj)
				return false
			})
			//楼盘id转名称
			function estateName(v){
				if(v!==null&&v!==""){
					switch(v)
						{
						case 1:
						  return "万科·皇马郦宫"
						  break;
						case 2:
							return "万科·四季松湖"
						  break;
						case 3:
							return "南部湾万科城"
						  break;
						case 4:
							return "万科·翡丽山"
						  break;
						case 5:
							return "万科·东江之星"
						  break;
						case 6:
							return "万科·幸福城"
						  break;
						case 7:
							return "万科·云城"
						  break;
						case 8:
							return "万科·城市花园"
						  break;
						case 9:
							return "万科·中央公园"
						  break;
						case 10:
							return "万科·珠江东岸"
						  break;	
						default:
						   return ""
						}
				}
			}
			

		})
	</script>

</html>